import router from './index'

router.beforeEach((to, from, next) => {
  if (to.matched.some(record => record.meta.requireAuth)){
    if (sessionStorage.getItem("user")) {
      next();
    } else {
      next({
        path: '/',
        query: {redirect: to.fullPath}
      })
    }
  } else {
    next();
  }
});


